﻿using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace NetCoreTest
{
    public class AsyncAwaitLab
    {
        public static async void ShowResult()
        {
            string result = await getHtmlFromBaidu();
            Console.WriteLine(result);
        }

        public static async Task<string> getHtmlFromBaidu()
        {
            HttpClient hc = new HttpClient();
            System.IO.StreamReader sr = new System.IO.StreamReader(await hc.GetStreamAsync("http://www.baidu.com"));
            return sr.ReadToEnd();
        }
    }
}
